<template>
  <div class="tabs-container flex-column">
    <van-tabs v-model:active="activeTab" animated swipeable sticky @click-tab="handleTabClick">
      <van-tab title="作品" name="post">
        <div class="video-list">
          <div v-if="!postList.total" class="empty-container">
            <van-empty description="还没有发布过作品" />
          </div>
          <div v-else class="video-grid scroll-y">
            <VideoGrid :videos="postList.videos" />
          </div>
        </div>
      </van-tab>
      <van-tab title="收藏" name="favorites">
        <div class="video-list">
          <div v-if="!collectList.total" class="empty-container">
            <van-empty description="还没有收藏作品" />
          </div>
          <div v-else>
            <VideoGrid :videos="collectList.collects" />
          </div>
        </div>
      </van-tab>
      <van-tab title="喜欢" name="likes">
        <div class="video-list">
          <div v-if="!likeList.total" class="empty-container">
            <van-empty description="还没有喜欢的作品" />
          </div>
          <div v-else>
            <VideoGrid :videos="likeList.likes" />
          </div>
        </div>
      </van-tab>
    </van-tabs>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import VideoGrid from '@/components/VideoList.vue'
import { useRouter } from 'vue-router'
const router = useRouter()
const activeTab = ref('post')
const handleTabClick = () => {
  router.replace({
    path: '/user/self',
    query: {
      showTab: activeTab.value,
    },
  })
}
const props = defineProps({
  postList: {
    type: Object,
    default: () => ({
      videos: [],
      total: 0,
    }),
  },
  collectList: {
    type: Object,
    default: () => ({
      collects: [],
      total: 0,
    }),
  },
  likeList: {
    type: Object,
    default: () => ({
      likes: [],
      total: 0,
    }),
  },
})
</script>

<style scoped>
.tabs-container {
  flex: 1;
  margin-bottom: var(--tabbar-height);
}

.van-tabs {
  display: flex;
  flex-direction: column;
}

:deep(.van-tabs__content) {
  flex: 1;
}

:deep(.van-tabs__nav) {
  flex-shrink: 0;
  background-color: var(--tabbar-background-color);
  padding: 0 30px;
}

.video-list {
  height: 100%;
}

.video-grid {
  height: 100%;
}

:deep(.van-tab) {
  flex: 1;
  height: var(--tab-height);
  min-width: 60px;
  padding: 0 12px;
}

:deep(.van-tab--active) {
  font-weight: var(--tab-font-weight);
  color: var(--tab-active-color);
}

:deep(.van-tabs__line) {
  background-color: var(--tab-line-color);
  height: 2px;
}
</style>
